<!-- 勾选协议 -->
<template>
	<view class="box-row">
		<uni-icons :type="agreement ? 'checkbox-filled' :  'circle'" size="40rpx" color="#39B056"
			@click="setAgreement">
		</uni-icons>
	
		<text style="margin-left: 12rpx;">已阅读并同意</text>
		<text @tap.stop="enterAgreement(1)" style="font-weight: bold;color: #58be6a;">《用户协议》</text>和
		<text @tap.stop="enterAgreement(2)" style="font-weight: bold;color: #58be6a;">《隐私协议》</text>
	</view>
</template>

<script>
	export default {
		props: {
			/**
			 * 是否勾选同意协议的回调方法
			 */
			submit:{
				type: Function,
				default: ()=>{}
			}
		},
		data() {
			return {
				agreement: false, // 是否勾选协议
			};
		},
		methods:{
			/**
			 * 前往用户协议和隐私协议
			 */
			enterAgreement(val) {
				let str = ''
			
				//用户协议
				if (val === 1) {
					str = '/pages/me/userAgreement'
				}
			
				//隐私协议
				if (val === 2) {
					str = '/pages/me/privacyAgreement'
				}
			
				uni.navigateTo({
					url: str
				})
			},
			
			/**
			 * 勾选协议
			 */
			setAgreement() {
				this.agreement = !this.agreement
				this.$emit('submit',this.agreement)
			},
		}
	}
</script>

<style lang="less" scoped>
	.box-row{
		// #flex(-,center,center);
		
	}
</style>
